#%RAML 1.0
title: Inventory Storage OAI-PMH view API
version: v1.1
protocols: [ HTTP, HTTPS ]
baseUri: http://github.com/org/folio/mod-inventory-storage

documentation:
  - title: OAI-PMH view API
    content: This documents the streaming API for the data needed for OAI-PMH

types:
  oaipmhInstances: !include oaipmh/oaipmhinstances.json
  oaipmhUpdatedInstanceIds: !include oaipmh/oaipmhupdatedinstanceids.json
  oaipmhEnrichedInstances: !include oaipmh/oaipmhenrichedinstances.json
  oaipmhInstanceIds: !include oaipmh/oaipmhinstanceids.json
  errors: !include raml-util/schemas/errors.schema

traits:
  language: !include raml-util/traits/language.raml
  validate: !include raml-util/traits/validation.raml

resourceTypes:
  collection-get: !include raml-util/rtypes/collection-get.raml

/oai-pmh-view:
  /instances:
    displayName: Stream API to get data for OAI-PMH
    type:
      collection-get:
       schemaCollection: oaipmhInstances
       exampleCollection: !include examples/oaipmhinstances.json
    get:
      description: Stream data for oai-pmh
      is:
        [validate]
      queryParameters:
        startDate:
          description: Lower bound for filtering instances by instances, items and holdings metadata update date. Accepted format YYYY-MM-DD or YYYY-MM-DDThh:mm:ssZ
          type: string
          required: false
        endDate:
          description: Upper bound for filtering instances by instances, items and holdings metadata update date
          type: string
          required: false
        deletedRecordSupport:
          description: Returns deleted records
          type: boolean
          required: false
          default: true
        skipSuppressedFromDiscoveryRecords:
          description: Configuration param which defines if discovery suppressed instance records should be skipped or not
          type: boolean
          required: false
          default: true
  /updatedInstanceIds:
    displayName: Stream API to get instances ids of updated oai records for OAI-PMH
    type:
      collection-get:
       schemaCollection: oaipmhUpdatedInstanceIds
       exampleCollection: !include examples/oaipmhupdatedinstanceids.json
    get:
      description: Stream updated instances ids for oai-pmh
      is:
        [validate]
      queryParameters:
        startDate:
          description: Lower bound for filtering instances by instances, items and holdings metadata update date
          type: string
          required: false
        endDate:
          description: Upper bound for filtering instances by instances, items and holdings metadata update date
          type: string
          required: false
        deletedRecordSupport:
          description: return deleted records
          type: boolean
          required: false
          default: true
        skipSuppressedFromDiscoveryRecords:
          description: Configuration param which defines if discovery suppressed instance records should be skipped or not
          type: boolean
          required: false
          default: true
  /enrichedInstances:
    displayName: Stream API to get instances with items and holdings for OAI-PMH
    post:
      description: Stream instances view data for oai-pmh
      is:
        [validate]
      body:
        application/json:
          description: List of instances Ids with skip suppressed from discovery configuration parameter
          type: oaipmhInstanceIds
          example: !include examples/oaipmhinstanceids.json
      responses:
        200:
          body:
            application/json:
              type: oaipmhEnrichedInstances
              example: !include examples/oaipmhenrichedinstances.json
